package com.knowvoyage.knowvoyageserver.pojo.entity;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.*;
import lombok.Data;
import java.time.LocalDateTime;

@Schema(description = "用户实体")
@Data
public class User {
    private Long userId;

    @NotBlank(message = "用户名不能为空")
    @Size(min = 2, max = 50, message = "用户名长度必须在2-50个字符之间")
    @Pattern(regexp = "^[\\u4e00-\\u9fa5a-zA-Z0-9_]+$",
            message = "用户名只能包含中文、字母、数字和下划线")
    private String name;

    @Min(value = 0, message = "性别值不合法")
    @Max(value = 2, message = "性别值不合法")
    private Integer sex = 0;

    @Pattern(regexp = "^1[3-9]\\d{9}$|^$",
            message = "手机号格式不正确")
    private String phone;

    @NotBlank(message = "密码不能为空")
    @Size(min = 6, max = 100, message = "密码长度必须在6-100个字符之间")
    private String password;

    @Pattern(regexp = "^(https?://)?([\\da-z.-]+)\\.([a-z.]{2,6})[/\\w .-]*/?$|^$",
            message = "头像URL格式不正确")
    private String avatar;

    private LocalDateTime createTime;
    private LocalDateTime lastLoginTime;

//    @Pattern(regexp = "^[a-zA-Z0-9_-]{28,32}$|^$",
//            message = "微信openid格式不正确")
    private String openid;

    private Boolean enable = true;

    @Min(value = 0, message = "角色值不合法")
    @Max(value = 1, message = "角色值不合法")
    private Long role = 0L;
}
